﻿ //事件上报
var vm = new Vue({
  el: '#app',
  data: function() {
    return {
      path: '',
      p: 1,
      pageSize: 20,
      actType: 0, //0:我发起的，1：@我的；2：公共 localStorage.getItem('actType')?localStorage.getItem('actType'):
      myUnread: 0, //我发起的未读数量
      atUnread: 0, //@我的未读数量
      publicUnread: 0, //公共未读数量
      loading: false,
      listData: []
    }
  },
  mounted: function() {
    var that = this;
    mui.init();
    that.getData(); //刷新数据
    mui.ready(function() {
      //#32↓↓↓
      mui('.mui-scroll-wrapper').scroll({
        deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
      });
    })
  },
  methods: {
    //获取数据
    getData: function(t) {
      //t:0:刷新,t:1:下一页
      var that = this;
      var urls = '';
      that.loading = true;
      switch (that.actType) {
        case 0:
          urls = '/getMyCreateEvents';
          break;
        case 1:
          urls = '/getAtEvents';
          break;
        case 2:
          urls = '/getPublicEvents';
          break;
      };
      $.getJSON(urls, {}, function(res) {
        that.listData = res.data;
        that.myUnread = res.myUnread;
        that.atUnread = res.atUnread;
        that.publicUnread = res.publicUnread;
        that.loading = false;
      })
    },
    //下拉刷新
    pulldownRefresh: function() {
      var that = this;
      that.getData(); //刷新数据
    },
    //上拉加载下一页
    pullupRefresh: function() {
      //目前无分页 ，暂不启用
      //      var that = this;
      //      that.getData(1); //下拉加载下一页数据
    },
    //类型切换
    bindChangeType: function(id) {
      var that = this;
      that.actType = id; //设置当前类型
      that.getData();
    },
    //进入详情
    goDetail: function(id) {
      var that = this;
      mui.openWindow({
        url: 'eventReporting-content.html?eventId=' + id,
        id: 'eventReporting-content.html'
      })
    }
  }
})
